package com.fc.backingbeans.calculators

import javax.validation.constraints.Max
import javax.validation.constraints.Min
import javax.validation.constraints.NotNull

import org.springframework.beans.factory.annotation.Autowired

import com.fc.calculators.BmiCalculator
import com.fc.entities.User
import com.fc.service.UserDetailsService
import com.fc.user.Gender

abstract class UserValueCalculatorBase {
	@Autowired private UserDetailsService userDetailsService

	@Min(1L)
	@Max(250L)
	@NotNull
	Integer height

	@Min(1L)
	@Max(300L)
	@NotNull
	Integer weight

	@Min(0L)
	@Max(100L)
	@NotNull
	Integer age

	@NotNull
	Gender gender

	BigDecimal result

	UserValueCalculatorBase() {
		reset()
	}

	abstract void calculate();


	/**
	 * feltölti a kalkulátor bemenetét a felhasználó adataival.
	 */
	void resetWithUserData() {
		User user = userDetailsService.currentUser
		age = user.age
		weight = user.weight
		height = user.height
		gender = user.gender
	}

	/**
	 * Beállítja az alapértelmezett értékeket.
	 */
	void reset() {
		height = null
		age = null
		weight = null
		gender = null
	}
}
